package org.example.controller;

import org.example.pojo.vo.PortalVo;
import org.example.service.HeadlineService;
import org.example.service.TypeService;
import org.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("portal")
@CrossOrigin
public class PortalController {

    @Autowired
    private TypeService typeService;

    @Autowired
    private HeadlineService headlineService;

    /**
     * 查询所有新闻类型
     *
     * @return 所有新闻类型的列表结果
     */
    @GetMapping("findAllTypes")
    public Result findAllTypes(){
        Result result = typeService.findAllTypes();
        return result;
    }


    /**
     * 分页查询新闻列表
     *
     * @param portalVo 门户查询条件对象（包含关键词、类型、分页信息）
     * @return 分页新闻列表结果
     */
    @PostMapping("findNewsPage")
    public Result findNewsPage(@RequestBody PortalVo portalVo){
        Result result = headlineService.findNewsPage(portalVo);
        return result;
    }

    /**
     * 显示新闻详情
     *
     * @param hid 新闻ID
     * @return 新闻详情结果
     */
    @PostMapping("showHeadlineDetail")
    public  Result showHeadlineDetail(Integer hid){
        Result result = headlineService.showHeadlineDetail(hid);
        return result;
    }

}